namespace pengpeng
{
    export class PPData
    {
        public version:string;
        public materials:Map<string,MaterialData>;
        public shapes:Map<string,ShapeData>;
        public assets:Map<string,AssetData>;
        public worlds:Map<string,WorldData>;

        constructor()
        {
            
        }
    }

    export class MaterialData
    {
        public name:string; //"name":"aa",
        public density:number; //"density":1,
        public friction:number; //"friction":0.3,
        public linearDamping:number; //"linearDamping":0,
        public angularDamping:number; //"angularDamping":0,
        public restitution:number; //"restitution":0

        constructor()
        {
            
        }
    }

    export class ShapeData
    {
        public static CIRCLE:string = "circle";
        public static RECTANGLE:string = "rectangle";
        public static POLGON:string = "polgon";


        public name:string;
        public type:string;
        public radius:number;
        public width:number;
        public height:number;

        constructor()
        {
            
        }
    }

    export class AssetData
    {
        public name:string;
        public type:string;
        public path:string;

        constructor()
        {
            
        }
    }

    export class BodyData
    {
        public static TYPE_STATIC:String = "static";
        public static TYPE_DYNAMIC:String = "dynamic";
        public static KINEMATIC:String = "kinematic";
        public name:string; //"name":"aa",
        public material:string; //"materialName":"aa",
        public materialData:MaterialData;
        public asset:string;//"assetType":"image",
        public assetData:AssetData;
        public shape:string;//"shapeName":"aa",
        public shapeData:ShapeData;//"shapeName":"aa",
        public type:string;//"type":"static,synamic,",
        public x:number;//"x":1,
        public y:number;//"y":1,
        public rotation:number; //"rotation":10,
        public gravityScale:number; //"gravityScale":1,
        public allowSleep:boolean; //"allowSleep":true,
        public fixedRotation:boolean; //"fixedRotation":true,
        public bullet:boolean; //"bullet":false,
        public active:boolean;//"active":true,
        public userData:any;//"userData":"aa",
        public collistionGroup:number;//"collistionGroup":1,
        public sensor:boolean; //"sensor":false

        constructor()
        {
            
        }
    }

    export class JointData
    {
        public name:string; //"name":"aa",
        public type:string;
        public bodyA:string;//    "bodyA":"aa",
        public bodyB:string;//    "bodyB":"bb",
        public anchorPointA:Point;//    "anchorPointA":[0,0],
        public anchorPointB:Point;//    "anchorPointB":[0,0],//distance
        public frequencyHz:number;//    "frequencyHz":4,//distance
        public dampingRation:number;//    "dampingRatio":4,//distance
        public lowerAngle:number;//    "lowerAngle":3.14,//revolute
        public upperAngle:number;//    "upperAngle":3.14,//revolute
        public enabledLimit:number;//    "enabledLimit":3.14,//revolute
        public maxMotorTorque:number;//    "maxMotorTorque":10,//revolute
        public motorSpeed:number;//    "motorSpeed":10,//revolute//prismatic
        public enableMotor:number;//    "enableMotor":10,//revolute//prismatic
        public lowerTranslation:number;//    "lowerTranslation":10,//prismatic
        public upperTranslateion:number;//    "upperTranslation":10,//prismatic
        //public enabledLimit:number;//    "enableLimit":10,//prismatic
        public maxMotorForce:number;//    "maxMotorForce":10,//prismatic
        public groundAnchor1:Point;//    "groundAnchor1":[0,0],//pulleys
        public groundAnchor2:Point;//    "groundAnchor2":[0,0],//pulleys
        public ratio:number;//    "ratio":1,//pulleys,gear
        public joint1:string;//    "joint1":"aa",//gear
        public joint2:string;//    "joint2":"aa",//gear

        constructor()
        {
            
        }
    }

    export class WorldData
    {
        public name:string;
        public gravity:Point;//"gravity":[0,1],
        public velocityIterations:number;//"velocityIterations":6,
        public positionIterations:number;//"positionIterations":2,
        public bodies:BodyData[] = [];
        public joints:JointData[] = [];
        
        constructor()
        {
            
        }
    }
}